package com.hotelsystem.reservations.filter;

import java.util.ArrayList;
import com.hotelsystem.reservations.rooms.Room;
import com.hotelsystem.reservations.rooms.RoomTypesEnum;

public class RoomFilter {

	/**
	 * Filter that returns a room object from a room number
	 * @param roomNumber
	 * @param allRooms
	 * @return rooms object with attribute room number
	 * @return NULL if a room is not found
	 */
	public Room filterNumber(int roomNumber, ArrayList<Room> allRooms)
	{		
		for (Room room : allRooms) 
		{
			if (room.getRoomNumber() == roomNumber) {
				return room;
			}
		}	
		return null;
	}	
	
	/**
	 * Filter that returns ArrayList of rooms by isSmokersFree and roomType
	 * @param roomType
	 * @param isSmokersFree
	 * @param allRooms
	 * @return filteredRooms (ArrayList)
	 */
	public ArrayList<Room> filterRoomTypeAndIsSmokersFree(RoomTypesEnum roomType, boolean isSmokersFree, ArrayList<Room> allRooms) {

		ArrayList<Room> filteredRooms = new ArrayList<Room>();
		for (Room room : allRooms) {
			if (room.getRoomType().equals(roomType) && room.isSmokersFree() == isSmokersFree) {
				filteredRooms.add(room);
			}
		}
		return filteredRooms;
	}

}
